import axios from '@/utils/request';


/**
 * 新增货款收款单
 */
export async function AddRecreceiptitem(params) {
    const res = await axios.post('/RecreceiptItem/AddRecreceiptitem',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 新增货款付款单
 */
export async function AddPaymentItem(params) {
    const res = await axios.post('/RecreceiptItem/AddPaymentItem',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 根据收款单id获取收款单信息
 */
export async function QueryRecreceiptitemViewById(id) {
    const res = await axios.get('/RecreceiptItem/QueryRecreceiptitemViewById/'+id);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 获取销售出库单查询分页列表
 */
 export async function QueryRecreceiptitemByCondition(params) {
    const res = await axios.post('/RecreceiptItem/QueryRecreceiptitemByCondition',params);
    if (res.data.code === 200) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.msg));
}


/**
 * 导入订单
 */
export async function ImportExcel(formData) {
    const res = await axios.post('/RecreceiptItem/ImportExcel',formData,{headers: {
        'Content-Type': 'multipart/form-data'
       }});
    return res.data;
}


/**
 * 更新收款单
 */
export async function UpdateRecreceipt(params) {
    const res = await axios.post('/RecreceiptItem/UpdateRecreceipt',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  * 收款单(过账)
  */
 export async function AuitRecreceipt(params) {
    const res = await axios.post('/RecreceiptItem/AuitRecreceipt',params);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}

 /**
  * 收款单(反过账)
  */
 export async function AntiRecreceipt(id) {
    const res = await axios.post('/RecreceiptItem/AntiRecreceipt?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}


 /**
  *作废收款单
  */
 export async function DeleteRecreceiptItem(id) {
    const res = await axios.post('/RecreceiptItem/DeleteRecreceiptItem?id='+id);
    if (res.data.code === 200) {
        return res.data.msg;
    }
    return Promise.reject(new Error(res.data.msg));
}
